package org.ccay.excel.meta;

import java.util.HashMap;
import java.util.Map;

/**
 * 单元格验证器的配置信息。
 * 	
 * @author chaowangbang
 * @since Mar 19, 2012
 */
public class ValidatorMeta implements java.lang.Cloneable{
	
	/**
	 * 验证器的类型
	 */
	private String type;
	
	/**
	 * 验证器相关的参数配置
	 */
	private Map<String, String> params = new HashMap<String, String>();
	
	/**
	 * @param type
	 */
	public ValidatorMeta(String type) {
		this.type = type;
	}
	
	/** 获取验证器的类型	
	 * @author chaowangbang
	 * @since Mar 19, 2012
	 * @return
	 */
	public String getType() {
		return this.type;
	}
	
	/** 添加一个参数定义
	 * @author chaowangbang
	 * @since Mar 19, 2012
	 * @param key
	 * @param value
	 */
	public void addParam(String key, String value) {
		this.params.put(key, value);
	}
	
	/** 获取参数定义列表
	 * @author chaowangbang
	 * @since Mar 19, 2012
	 * @return
	 */
	public Map<String, String> getParams() {
		return this.params;
	}

	/**
	 * 	添加一个参数Map
	 * @author chaowangbang
	 * @since 2012-3-20
	 * @param params
	 */
	public void setParams(Map<String, String> params) {
		this.params = params;
	}
	
	public ValidatorMeta copy() throws CloneNotSupportedException{
		ValidatorMeta copyValidatorMeta = (ValidatorMeta) this.clone();
		HashMap<String, String> copyParams = (HashMap<String, String>) this.getParams();
		copyValidatorMeta.setParams((HashMap<String, String>)copyParams.clone());
		return copyValidatorMeta;
	}

}
